﻿#pragma once

#ifndef QCEFSETTING_H
#define QCEFSETTING_H

#include <QtCore>
#include <QtGui>
#include <QtWidgets>

#include "QCefDebug.h"
#include "QCefHeader.h"

class QCefSetting
{
public:
    inline static QCefSetting* instance() { return ms_instance; }

protected:
    static QCefSetting* ms_instance;   //

public:
    QCefSetting();
    ~QCefSetting();

public:
    CefSettings & getCefSettings() { return m_cefSettings; }

    void setNoSandbox(bool disable = true);
    bool getNoSandbox();

    void setSubprocessPath(const QString & strFilePath = "");
    QString getSubprocessPath();

    void setMultiThreadMsgLoop(bool bMultiThread = false);
    bool getMultiThreadMsgLoop();

    void setExternalMsgPump(bool bExtPump = true);
    bool getExternalMsgPump();

    void setOsr(bool bOsr = false);
    bool getOsr();

    void setCachePath(const QString & strPath = "");
    QString getCachePath();

    void setRootCachePath(const QString & strPath = "");
    QString getRooCachePath();

    void setUserDataPath(const QString & strPath = "");
    QString getUserDataPath();

    void setPersistSessionCookies(bool bPersist = true);
    bool getPersistSessionCookies();

    void setPersistUserPreferences(bool bPersist = true);
    bool getPersistUserPreferences();

    void setUserAgent(const QString & strAgent = "");
    QString getUserAgent();

    void setUserAgentProduct(const QString & strAgent = "");
    QString getUserAgentProduct();

    void setLocale(const QString & strLocale = "");
    QString getLocale();

    void setLogFile(const QString & strLogFile = "");
    QString getLogFile();

    void setLogSeverity(cef_log_severity_t iLogSeverity = LOGSEVERITY_DISABLE);
    cef_log_severity_t getLogSeverity();

    void setResourcesPath(const QString & strPath = "");
    QString getResourcesPath();

    void setLocalesPath(const QString & strPath = "");
    QString getLocalesPath();

    void setAcceptLanguage(const QString & strLanguage = "");
    QString getAcceptLanguage();

protected:
    CefSettings m_cefSettings;

protected:
    int init();
};

#endif // QCEFSETTING_H
